package com.atguigu.gmall.file;

import org.junit.Test;

import java.util.concurrent.*;

/**
 * 异步 编排
 */
public class CompletableFutureDemo {

    public static ThreadPoolExecutor threadPoolExecutor =
            new ThreadPoolExecutor(2,
                    5,
                    10,
                    TimeUnit.SECONDS,
                    new ArrayBlockingQueue(100)
            );
    //创建一个多线程
    public static void main(String[] args) throws Exception {

        System.out.println(Thread.currentThread().getName());
        CompletableFuture<String> result = CompletableFuture.supplyAsync(() -> {
            System.out.println(Thread.currentThread().getName());
            return "one";
        }, threadPoolExecutor);
        System.out.println(result.get());

   /*     CompletableFuture.runAsync(() -> {
            System.out.println("runnable");
        });*/
    }
}
